<?php
require_once '/var/jenkins_home/scripts/oss/sdk/autoload.php';

use OSS\OssClient;
use OSS\Core\OssException;

$accessKeyId = $argv[1];
$accessKeySecret = $argv[2];
$endpoint = "http://oss-cn-shenzhen.aliyuncs.com";
$bucket= $argv[3];
$myDomain = $argv[4];

try {
    $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
    $ossClient->addBucketCname($bucket, $myDomain);
} catch (OssException $e) {
    printf(__FUNCTION__ . ": FAILED\n");
    printf($e->getMessage() . "\n");
    return;
}
print(__FUNCTION__ . "$bucket" . "\t" . "$myDomain" . "\t" . ": OK" . "\n");
